package top.jx.file;

import lombok.SneakyThrows;
import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import top.opm.config.FileServiceConfig;
import top.opm.config.LocalFilePatch;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.UUID;

public class FileUtil {


    public static long getFileSize(File file) {
        if (!file.exists() || !file.isFile()) {
            System.out.println("文件不存在");
            return -1;
        }
        return file.length();
    }

    public static String getFileSuffix(File file) {
        if (!file.exists() || !file.isFile()) {
            System.out.println("文件不存在");
            return "";
        }
        return getFileSuffix(file.getName());
    }

    public static String getFileSuffix(String filePath) {
        return filePath.substring(filePath.lastIndexOf("."));
    }
}
